package com.lsw.jgyf.ui.activity;

import android.widget.TextView;

import com.lsw.jgyf.R;
import com.lsw.jgyf.adapter.CompanyDetailsAdapter;
import com.lsw.jgyf.model.StagingCompanyDetailsModel;
import com.lsw.jgyf.ui.base.activity.TitleBarActivity;
import com.lsw.view.MyListView;

import java.util.ArrayList;
import java.util.List;

import butterknife.BindView;

/**
 * Created by lsw on 2018/7/12.
 */

public class CompanyDetailsActivity extends TitleBarActivity<CompanyDetailsPresenter> implements CompanyDetailsContract.View {

    @BindView(R.id.listview)
    MyListView listview;
    CompanyDetailsAdapter companyDetailsAdapter;
    @BindView(R.id.tv_call_phone)
    TextView tv_call_phone;
    @BindView(R.id.tv_name)
    TextView tv_name;
    @BindView(R.id.tv_username)
    TextView tv_username;
    @BindView(R.id.tv_phone)
    TextView tv_phone;
    private String id;

    @Override
    protected void initInjector() {
        mActivityComponent.inject(this);
    }

    @Override
    protected void initEventAndData() {
        companyDetailsAdapter = new CompanyDetailsAdapter(mContext);
        listview.setAdapter(companyDetailsAdapter);
        id = getIntent().getStringExtra("id");
        mPresenter.getData(id);
        tv_call_phone.setOnClickListener(v -> call(tv_phone.getText().toString().trim()));
    }

    @Override
    protected int setContentLayoutView() {
        return R.layout.activity_company_details;
    }

    @Override
    public void setData(StagingCompanyDetailsModel model) {
        if (model != null) {
            tv_name.setText(model.getName());
            tv_username.setText(model.getSa_name());
            tv_phone.setText(model.getSa_mobile());
            companyDetailsAdapter.setData(model.getProduct_list());
        }
    }

    @Override
    protected void setActionBarDetail() {

    }
    @Override
    public void openlogin() {
        OpenLogin();
    }
}
